$j(function(){
	$j('.gotop').gotop({});
});

(function ($) {
    $.fn.gotop = function (options) {

        var settings = $.extend({
            'content': 980,
            'bottom': 30,
            'margin': "none",
            'position': "right",
            'scrollTop': 100,
            'duration': 700
        }, options);

        var win = $(window);
        var top = this;

        //is there some place for my return to the top button?
        function hasPlace() {
            var place = true;
            if (settings.margin == "none") {
                if (win.width() < (settings.content + (top.width() * 2) + 4)) place = false;
            }
            else {
                if (win.width() < (settings.content + ((top.width() + settings.right) * 2) + 4)) place = false;
            }
            return place;
        }

        //Put our return to top button at his place
        function placeTop() {
            var pos = (((win.width() - settings.content) / 2) - top.width()) / 2;
            if (settings.position == "left" || settings.position == "l") top.css({ "left": pos + "px" });
            else top.css({ "right": pos + "px" });
        }

        //Can we show this button?
        function showTop() {
            if (win.scrollTop() > settings.scrollTop) {
                top.fadeIn();
                if ($.browser.msie && ($.browser.version == "6.0")) {
                    var thisTop = win.scrollTop() + win.height() - top.height()- settings.bottom;
                    top.css("top", thisTop + "px");
                }
            }
            else top.fadeOut();
        }

        if (!hasPlace()) this.hide();
        if (settings.margin == "none") placeTop();
        else if (settings.position == "left" || settings.position == "l") top.css({ "left": settings.margin + "px" });
        else top.css({ "right": settings.margin + "px" });
        showTop();

        //RESIZE
        win.resize(function () {
            if (hasPlace()) top.fadeIn();
            else top.fadeOut();

            if (settings.margin == "none") placeTop();
        });

        //SCROLL
        win.scroll(function () {
            showTop();
        });

        if ($.browser.msie && ($.browser.version == "6.0")) {
            top.css({ "position": "absolute", "cursor": "pointer" });
        } else {
            top.css({ "position": "fixed", "cursor": "pointer", "bottom": settings.bottom + "px" });
        }

        return top
        .click(function () {
            $('body,html').animate({ scrollTop: 0 }, settings.duration);
        });
		

    };
})(jQuery);

//hide the select tag of IE6  
function hideselectIE6(){
	if ($j.browser.msie/* && $.browser.version < 7*/) {
		$j("select.ie6").each(function(i){  
			this.style.visibility= 'hidden';  
	   });  
    } 
}


//show the select tag of IE6
function showselectIE6(){
	if ($j.browser.msie/* && $.browser.version < 7*/) {
		$j("select.ie6").each(function(i){
			this.style.visibility = 'visible';
		});
	}
}

//showalert
function sConfirm(e,f,c,modal){
	hideselectIE6();
	var $onion = $j("div.black_opacity");
	//if(modal){
		if($onion.length > 0){
			$onion.fadeOut(15).fadeIn(300);
		}else{
			$j("<div class='black_opacity'></div>").css({"height":$j(document).height(),"opacity":"0.5"}).detach().appendTo("body").fadeOut(15).fadeIn(300);
		}
	//}		
	
	var $cdlg = $j("div.confirm_dialog");
	if($cdlg.length > 0){
		$cdlg.fadeOut(15).fadeIn(300);
	}else{
		$j("<div class='confirm_dialog'><label></label><p class='pword'></p><div class='box-button'><a class='black-btn width90 margin-left-01 sucess_confirm' href='javascript:void(0)'><em class='fLeft'>确认</em><span class='fLeft'> </span></a>&nbsp;&nbsp;&nbsp;&nbsp;<a class='black-btn-01 width90 margin-left-02 cancel_confirm' href='javascript:void(0)'><em class='fLeft'>取消</em><span class='fLeft'> </span></a></div><img src='"+static_base+"/images/box_03.jpg' class='cross_cha close' /></div>").detach().appendTo("body").fadeOut(15).fadeIn(300);
	}
	
	$j('.confirm_dialog label').html(e);$j('.confirm_dialog .pword').html(f);
	$j(".confirm_dialog .sucess_confirm").attr("confirm",true);
	
	$j(".confirm_dialog .cross_cha,.confirm_dialog .cancel_confirm").click(
		function(){
			$j(".black_opacity").fadeOut(15);
			$j(".confirm_dialog").fadeOut(15);
			showselectIE6();
		}				 
	);
	$j(".confirm_dialog .sucess_confirm").click(
			function(){
				if($j(this).attr("confirm")){
					$j(this).removeAttr("confirm");
					loxia.hitch(c)();
				}				
				$j(".black_opacity").fadeOut(15);
				$j(".confirm_dialog").fadeOut(15);
				showselectIE6();
			}				 
		);
	if ($j.browser.msie && ($j.browser.version == "6.0") && !$j.support.style) {
		var sc_top=$j(window).scrollTop();
		$j(".confirm_dialog").css("top",sc_top+150);
	}

};

function sAlert(e,f,c,modal){
	hideselectIE6();
	var $onion = $j("div.black_opacity");
	//if(modal){
		if($onion.length > 0){
			$onion.fadeOut(15).fadeIn(300);
		}else{
			$j("<div class='black_opacity'></div>").css({"height":$j(document).height(),"opacity":"0.5"}).detach().appendTo("body").fadeOut(15).fadeIn(300);
		}	
	//}	
	
	var $adlg = $j("div.alert_dialog");
	if($adlg.length > 0){
		$adlg.fadeOut(15).fadeIn(300);
	}else{
		$j("<div class='alert_dialog'><label></label><p class='pword' style='text-align:center;'></p><div class='box-button'><a class='black-btn width90 margin-left-01 sucess_confirm' href='javascript:void(0)'><em class='fLeft'>确认</em><span class='fLeft'> </span></a></div><img src='"+static_base+"/images/box_03.jpg' class='cross_cha close' /></div>").detach().appendTo("body").fadeOut(15).fadeIn(300);
	}
	
	$j('.alert_dialog label').html(e);$j('.alert_dialog .pword').html(f);
	
	$j(".alert_dialog .sucess_confirm").attr("confirm",true);
	
	$j(".alert_dialog .cross_cha,.alert_dialog .sucess_confirm").click(
		function(){
			if($j(".alert_dialog .sucess_confirm").attr("confirm")){
				$j(".alert_dialog .sucess_confirm").removeAttr("confirm");
				if(c)
					loxia.hitch(c)();
			}				
			$j(".black_opacity").fadeOut(15);
			$j(".alert_dialog").fadeOut(15);
			showselectIE6();
		}				 
	);
	if ($j.browser.msie && ($j.browser.version == "6.0") && !$j.support.style) {
		var sc_top=$j(window).scrollTop();
		$j(".alert_dialog").css("top",sc_top+150);
	}
};

function changeImage(t) {
	$j(t).attr("src", base + '/captcha?' + new Date().getTime());
}